﻿<?php
set_time_limit ( 0 );
$prefix = C ( 'DB_PREFIX' );

$map ['name'] = 'SYSTEM_UPDATRE_VERSION';
$res = M ( 'config' )->where ( $map )->getField ( 'value' );

if ($res < 20140711) {
	$this->mtReturn(300, '该补丁包需要先升级到7月11号发布补丁包版本再升级' );
	
	exit ();
}
if ($res >= 20150127) {
	$this->mtReturn(300, '请不要重复执行数据库升级'  );
	
	exit ();
}

unset ( $map );

$install_sql = './update/update.sql';
execute_sql_file ( $install_sql );



$map ['name'] = 'SYSTEM_UPDATRE_VERSION';
$res = M ( 'config' )->where ( $map )->setField ( 'value', 20150127 );
S ( 'DB_CONFIG_DATA', null );

$this->mtReturn(200,'更新完毕，请清理缓存！','','forward',U('Update/index'));